package java_array;

import java.util.Random;

/**
 * 数组求比average小的个数
 */
public class 数组求比average小的个数 {

    public static void main(String[] args) {
        Random r = new Random();
        int arr[] = new int[10];
        int num = 0;
        for (int i = 0; i < arr.length; i++) {
            int number = r.nextInt(100) + 1;
            arr[i] = number;
            num += arr[i];
        }
        int avg = num / arr.length;
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] < avg) {
                count++;
            }
        }
        System.out.println("平均值是：" + avg);
        System.out.println("比平均数小的元素个数有" + count + "个");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

    }
}